<?php 

class Gt_Pos_Block_Adminhtml_Order_Promotion extends Mage_Core_Block_Template {
	public function getAllPromotions(){
	
		$storeId = Mage::app()->getStore()->getId();	
		//get now time for compare
		$todayDate = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));	
	
		//reference block Mage_Adminhtml_Block_Promo_Quote_Grid, Mage_Adminhtml_Block_Promo_Catalog_Grid
		/** @var $collection Mage_CatalogRule_Model_Mysql4_Rule_Collection */
        $catalogRules = Mage::getModel('catalogrule/rule')
            ->getResourceCollection();
        $catalogRules->addWebsitesToResult();
		$catalogRules->addFieldToFilter('is_active', array('eq' => 1))
					->addFieldToFilter('from_date', array(
						array('date'=>true, 'to'=> $todayDate),
						array('null' => true)
					))
					->addFieldToFilter('to_date', array(
					array('date'=>true, 'from'=> $todayDate),
					array('null' => true)
					));
	
		/** @var $collection Mage_SalesRule_Model_Mysql4_Rule_Collection */
		$cartRules = Mage::getModel('salesrule/rule')
			->getResourceCollection();
        $cartRules->addWebsitesToResult();
		$cartRules->addFieldToFilter('is_active', array('eq' => 1))
					->addFieldToFilter('from_date', array(
						array('date'=>true, 'to'=> $todayDate),
						array('null' => true)
					))
					->addFieldToFilter('to_date', array(
					array('date'=>true, 'from'=> $todayDate),
					array('null' => true)
					));
		
		if($catalogRules->getSize() > 0 || $cartRules->getSize() > 0){
			$result = null;
			if($catalogRules->getSize() > 0)
				$result['catalog_rules'] = $catalogRules;
			if($cartRules->getSize() > 0)
				$result['cart_rules'] = $cartRules;
				
			return $result;
		}
		
		return false;
	}
}